package com.wc.alorithm_luogu._BFS.马的遍历;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

/**
 * @Author congge
 * @Date 2025/1/10 20:06
 * @description
 * https://www.luogu.com.cn/problem/P1443
 */
public class Main {
    /**
     * 思路：
     * 最短路
     * 典型的BFS
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 410, INF = 0x3f3f3f3f;
    static int[][] f = new int[N][N];
    static int[][] q = new int[N * N][2];
    static int[] dx = {-1, 1, -2, 2, -2, 2, -1, 1}, dy = {-2, -2, -1, -1, 1, 1, 2, 2};
    static int n, m, x, y;

    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        x = sc.nextInt();
        y = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            Arrays.fill(f[i], 1, m + 1, INF);
        }
        f[x][y] = 0;
        int hh = 1, tt = 1;
        q[1][0] = x;
        q[1][1] = y;
        while (hh <= tt) {
            int[] t = q[hh++];
            int x = t[0], y = t[1];
            for (int i = 0; i < 8; i++) {
                int a = x + dx[i], b = y + dy[i];
                if (a > n || a < 1 || b > m || b < 1) continue;
                if (f[a][b] > f[x][y] + 1) {
                    f[a][b] = f[x][y] + 1;
                    q[++tt][0] = a;
                    q[tt][1] = b;
                }
            }
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (f[i][j] == INF) out.print(-1 + " ");
                else out.print(f[i][j] + " ");
            }
            out.println();
        }
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

